Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(performance): Update performance score calculation to checking profiles after the first match #3804

Merged

Conversation

edwardgou-sentry
Copy link
Contributor

@edwardgou-sentry edwardgou-sentry commented Jul 9, 2024

Updates the performance score calculation to break after find a profile with a matching condition. This prevents any subsequent matching profiles from overwriting calculated performance scores. This is needed because we will be adding a default fallback profile with a condition matching on any to the bottom of the profiles list.

#skip-changelog

@edwardgou-sentry edwardgou-sentry self-assigned this Jul 9, 2024
@edwardgou-sentry edwardgou-sentry requested a review from a team July 9, 2024 19:54
@edwardgou-sentry edwardgou-sentry marked this pull request as ready for review July 9, 2024 19:54
@edwardgou-sentry edwardgou-sentry requested a review from a team as a code owner July 9, 2024 19:54
Copy link
Member

@mjq mjq left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd get an ingest review too but this LGTM 👍

@@ -946,6 +946,7 @@ pub fn normalize_performance_score(
);
}
}
break; // Stop after the first matching profile.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop has become quite large and contains a few continue and break statements now, which seems error-prone. I think we could refactor this into a two-step approach that first finds a profile that matches all conditions, then runs calculations with that profile.

let Some(measurements) = event.measurements.value_mut() { else return };

let Some(profile) = performance_score.profiles.find(|profile| {
    profile.condition.is_some_and(|condition| condition.matches(event))
    && components_match_measurement(&profile.score_components, &measurements)
) { else return };

// ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 sounds good, i'll follow this up with a refactor pr!

@edwardgou-sentry edwardgou-sentry merged commit 447507c into master Jul 11, 2024
24 of 25 checks passed
@edwardgou-sentry edwardgou-sentry deleted the egou/feat/performance-score-stop-after-first-match branch July 11, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants